﻿using System;

namespace _2_Array
{
    class Program
    {
        static int read()
        {
            bool isOK = false; int res = 0;
            while (isOK == false)
            {
                try
                {
                    res = int.Parse(Console.ReadLine());
                    isOK = true;
                }
                catch
                {
                    Console.WriteLine("请重新输入此行");
                }
            }
            return res;
        }
        static void Main(string[] args)
        {
            Console.Write("输入整数的个数：");
            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            int Min = 0, Max = 0, total = 0;
            Console.WriteLine("请一行输入一个整数：");
            for (int i = 0; i < n; i++)
            {
                arr[i] = read();
                if (i == 0) Min = Max = total = arr[i];
                else
                {
                    Min = (arr[i] < Min) ? arr[i] : Min;
                    Max = (arr[i] > Max) ? arr[i] : Max;
                    total += arr[i];
                }
            }
            Console.WriteLine("Max is {0}, Min is {1}, Avg is {2}, Total is {3}", Max, Min, (double)total / n, total);
        }
    }
}
